// pages/supplier/supplier.js
import goodsApi from '../../service/goodsApi'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    supplierId: '',
    logo: '',
    name: '',
    address: '',
    qualificationList: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      supplierId: options.id
    })
    this.getSupplierInfo()
  },
  getSupplierInfo: function () {
    //获取供应商信息
    let that = this
    goodsApi.getSupplierInfo({
      supplierId: that.data.supplierId
    }).then((res) => {
      console.log()
      if (app.globalData.codeConfig.errCode.SUCCESS_CODE === res.data.errCode) {
        let result = res.data.data
        that.setData({
          logo: result.logo,
          name: result.name,
          address: result.address.substr(0, 7) + '.....' + result.address.substr(-8, 8),
          completeAddress: result.address,
          qualificationList: [...result.qualification]
        })
      }
    }).catch((res) => {})
  },
  copyAddress (e) {
    let that = this
    wx.setClipboardData({
      data: that.data.completeAddress
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }

})